package com.xiongda.service.impl;

import com.xiongda.common.ServerResponse;
import com.xiongda.dao.SafetyProblemMapper;
import com.xiongda.dto.SafetyProblemDto;
import com.xiongda.pojo.SafetyProblem;
import com.xiongda.service.SafetyProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 安全问题服务层实现
 * @author 缪琼
 */
@Service
public class SafetyProblemServiceImpl implements SafetyProblemService {

    @Autowired
    private SafetyProblemMapper safetyProblemMapper;

    @Override
    public ServerResponse checkQuestion(SafetyProblemDto safetyProblemDto) {
        SafetyProblem safetyProblem = safetyProblemMapper.get(safetyProblemDto.getUserId());
        if (safetyProblem.getAnswerOne().equals(safetyProblemDto.getAnswerOne()) &&
                safetyProblem.getAnswerTwo().equals(safetyProblemDto.getAnswerTwo()) &&
                safetyProblem.getAnswerThree().equals(safetyProblemDto.getAnswerThree()))
            return ServerResponse.createBySuccess(safetyProblem);
        return ServerResponse.createByErrorMessage("答案不匹配");
    }
}
